home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
501-525
/
disk_509
/
multi_player
/
sources
/
amreplay.s
< prev
next >
Wrap
Text File
|
1992-05-06
|
13KB
|
737 lines
; STARTREKKER 1.2 AM REPLAYROUTINE
;
; BY BJOERN WESEN / EXOLON OF FAIRLIGHT
; Call mt_init, then mt_music each frame, call mt_end to stop
; NOTE! The mt_amwaveforms have to reside in CHIPMEM! Therefore the ORG
; below...
; !!!!
XDEF _st_init,_st_music,_st_end
XREF _adr_data,_adr_data2
; !!!!
_st_init:
; !!!!
move.l _adr_data,a0
lea $3b8(a0),a1
moveq #$7f,d0
moveq #0,d2
moveq #0,d1
mt_lop2:move.b (a1)+,d1
cmp.b d2,d1
ble.s mt_lop
move.l d1,d2
mt_lop: dbf d0,mt_lop2
addq.b #1,d2
asl.l #8,d2
asl.l #2,d2
lea 4(a1,d2.l),a2
lea mt_samplestarts(pc),a1
add.w #42,a0
moveq #$1e,d0
mt_lop3:clr.l (a2)
move.l a2,(a1)+
moveq #0,d1
move.w (a0),d1
clr.b 2(a0)
asl.l #1,d1
add.l d1,a2
add.l #30,a0
dbf d0,mt_lop3
or.b #2,$bfe001
move.b #6,mt_speed
moveq #0,d0
lea $dff000,a0
move.w d0,$a8(a0)
move.w d0,$b8(a0)
move.w d0,$c8(a0)
move.w d0,$d8(a0)
clr.b mt_songpos
clr.b mt_counter
clr.w mt_pattpos
rts
_st_end:
clr.w $dff0a8
clr.w $dff0b8
clr.w $dff0c8
clr.w $dff0d8
move.w #$f,$dff096
rts
_st_music:
move.l _adr_data,a0
addq.b #1,mt_counter
move.b mt_counter(pc),d0
cmp.b mt_speed(pc),d0
blt mt_nonew
clr.b mt_counter
move.l _adr_data,a0
lea $c(a0),a3
lea $3b8(a0),a2
lea $43c(a0),a0
moveq #0,d0
moveq #0,d1
move.b mt_songpos(pc),d0
move.b (a2,d0.w),d1
lsl.w #8,d1
lsl.w #2,d1
add.w mt_pattpos(pc),d1
clr.w mt_dmacon
lea $dff0a0,a5
lea mt_voice1(pc),a4
bsr mt_playvoice
addq.l #4,d1
lea $dff0b0,a5
lea mt_voice2(pc),a4
bsr mt_playvoice
addq.l #4,d1
lea $dff0c0,a5
lea mt_voice3(pc),a4
bsr mt_playvoice
addq.l #4,d1
lea $dff0d0,a5
lea mt_voice4(pc),a4
bsr mt_playvoice
bsr mt_wait
move.w mt_dmacon(pc),d0
or.w #$8000,d0
move.w d0,$dff096
bsr mt_wait
mt_nodma:
lea $dff000,a3
lea mt_voice1(pc),a4
move.l $a(a4),$a0(a3)
move.w $e(a4),$a4(a3)
tst.w 30(a4)
bne.s mt_nov1
move.w $12(a4),$a8(a3)
mt_nov1:lea mt_voice2(pc),a4
move.l $a(a4),$b0(a3)
move.w $e(a4),$b4(a3)
tst.w 30(a4)
bne.s mt_nov2
move.w $12(a4),$b8(a3)
mt_nov2:lea mt_voice3(pc),a4
move.l $a(a4),$c0(a3)
move.w $e(a4),$c4(a3)
tst.w 30(a4)
bne.s mt_nov3
move.w $12(a4),$c8(a3)
mt_nov3:lea mt_voice4(pc),a4
move.l $a(a4),$d0(a3)
tst.w 30(a4)
bne.s mt_nov4
move.w $e(a4),$d4(a3)
move.w $12(a4),$d8(a3)
mt_nov4:add.w #$10,mt_pattpos
cmp.w #$400,mt_pattpos
bne.s mt_exit
mt_next:clr.w mt_pattpos
clr.b mt_break
move.l _adr_data,a0
addq.b #1,mt_songpos
and.b #$7f,mt_songpos
move.b $3b6(a0),d0
cmp.b mt_songpos(pc),d0
bne.s mt_exit
move.b $3b7(a0),mt_songpos
mt_exit:tst.b mt_break
bne.s mt_next
bra mt_amhandler
mt_wait:moveq #4,d3
mt_wai2:move.b $dff006,d2
mt_wai3:cmp.b $dff006,d2
beq.s mt_wai3
dbf d3,mt_wai2
moveq #8,d2
mt_wai4:dbf d2,mt_wai4
mt_nonew:
lea mt_voice1(pc),a4
lea $dff0a0,a5
bsr mt_com
lea mt_voice2(pc),a4
lea $dff0b0,a5
bsr mt_com
lea mt_voice3(pc),a4
lea $dff0c0,a5
bsr mt_com
lea mt_voice4(pc),a4
lea $dff0d0,a5
bsr mt_com
bra.s mt_exit
mt_mulu:
dc.w 0,$1e,$3c,$5a,$78,$96,$b4,$d2,$f0,$10e,$12c,$14a
dc.w $168,$186,$1a4,$1c2,$1e0,$1fe,$21c,$23a,$258,$276
dc.w $294,$2b2,$2d0,$2ee,$30c,$32a,$348,$366,$384,$3a2
mt_playvoice:
move.l (a0,d1.l),(a4)
moveq #0,d2
move.b 2(a4),d2
lsr.b #4,d2
move.b (a4),d0
and.b #$f0,d0
or.b d0,d2
beq mt_oldinstr
lea mt_samplestarts-4(pc),a1
move.w d2,34(a4)
move.w d2,d0
mulu #120,d0
move.l a0,-(sp)
move.l _adr_data2,a0
lea 24(a0,d0.l),a0
clr.w 30(a4)
cmp.w #"AM",(a0)
bne.s mt_noa9
move.w 6(a0),d0
lsr.w #2,d0
st 30(a4)
mt_noa9:move.l (sp)+,a0
asl.w #2,d2
move.l (a1,d2.l),4(a4)
lsr.w #2,d2
mulu #30,d2
move.w (a3,d2.w),8(a4)
tst.w 30(a4)
beq.s mt_noa8
move.w d0,$12(a4)
bra.s mt_noa7
mt_noa8:move.w 2(a3,d2.w),$12(a4)
mt_noa7:moveq #0,d3
move.w 4(a3,d2.w),d3
tst.w d3
beq.s mt_noloop
move.l 4(a4),d0
asl.w #1,d3
add.l d3,d0
move.l d0,$a(a4)
move.w 4(a3,d2.w),d0
add.w 6(a3,d2.w),d0
move.w d0,8(a4)
bra.s mt_hejaSverige
mt_noloop:
move.l 4(a4),d0
add.l d3,d0
move.l d0,$a(a4)
mt_hejaSverige:
move.w 6(a3,d2.w),$e(a4)
mt_oldinstr:
move.w (a4),d0
and.w #$fff,d0
beq mt_com2
tst.w 30(a4)
bne.s mt_rambo
tst.w 8(a4)
beq mt_stopsound
tst.b $12(a4)
bne mt_stopsound
move.b 2(a4),d0
and.b #$f,d0
cmp.b #5,d0
beq mt_setport
cmp.b #3,d0
beq mt_setport
mt_rambo:
move.w (a4),$10(a4)
and.w #$fff,$10(a4)
move.w $1a(a4),$dff096
clr.b $19(a4)
tst.w 30(a4)
beq.s mt_noaminst
move.l a0,-(sp)
move.w 34(a4),d0
mulu #120,d0
move.l _adr_data2,a0
lea 24(a0,d0.l),a0
moveq #0,d0
move.w 26(a0),d0
lsl.w #5,d0
add.l #mt_amwaveforms,d0
move.l d0,(a5)
move.w #16,4(a5)
move.l d0,$a(a4)
move.w #16,$e(a4)
move.w 6(a0),32(a4)
move.l #1,36(a4)
move.w 34(a0),d0
move.w d1,-(sp)
move.w $10(a4),d1
lsl.w d0,d1
move.w d1,$10(a4)
move.w d1,6(a5)
move.w (sp)+,d1
move.l (sp)+,a0
bra.s mt_juck
mt_noaminst:
move.l 4(a4),(a5)
move.w 8(a4),4(a5)
move.w $10(a4),6(a5)
mt_juck:move.w $1a(a4),d0
or.w d0,mt_dmacon
bra mt_com2
mt_stopsound:
move.w $1a(a4),$dff096
bra mt_com2
mt_setport:
move.w (a4),d2
and.w #$fff,d2
move.w d2,$16(a4)
move.w $10(a4),d0
clr.b $14(a4)
cmp.w d0,d2
beq.s mt_clrport
bge mt_com2
move.b #1,$14(a4)
bra mt_com2
mt_clrport:
clr.w $16(a4)
rts
mt_port:move.b 3(a4),d0
beq.s mt_port2
move.b d0,$15(a4)
clr.b 3(a4)
mt_port2:
tst.w $16(a4)
beq.s mt_rts
moveq #0,d0
move.b $15(a4),d0
tst.b $14(a4)
bne.s mt_sub
add.w d0,$10(a4)
move.w $16(a4),d0
cmp.w $10(a4),d0
bgt.s mt_portok
move.w $16(a4),$10(a4)
clr.w $16(a4)
mt_portok:
move.w $10(a4),6(a5)
mt_rts: rts
mt_sub: sub.w d0,$10(a4)
move.w $16(a4),d0
cmp.w $10(a4),d0
blt.s mt_portok
move.w $16(a4),$10(a4)
clr.w $16(a4)
move.w $10(a4),6(a5)
rts
mt_sin: dc.b 0,$18,$31,$4a,$61,$78,$8d,$a1,$b4,$c5,$d4,$e0,$eb,$f4
dc.b $fa,$fd
dc.b $ff,$fd,$fa,$f4,$eb,$e0,$d4,$c5,$b4,$a1,$8d,$78,$61
dc.b $4a,$31,$18
mt_vib: move.b $3(a4),d0
beq.s mt_vib2
move.b d0,$18(a4)
mt_vib2:move.b $19(a4),d0
lsr.w #2,d0
and.w #$1f,d0
moveq #0,d2
move.b mt_sin(pc,d0.w),d2
move.b $18(a4),d0
and.w #$f,d0
mulu d0,d2
lsr.w #7,d2
move.w $10(a4),d0
tst.b $19(a4)
bmi.s mt_vibsub
add.w d2,d0
bra.s mt_vib3
mt_vibsub:
sub.w d2,d0
mt_vib3:move.w d0,6(a5)
move.b $18(a4),d0
lsr.w #2,d0
and.w #$3c,d0
add.b d0,$19(a4)
rts
mt_arplist:
dc.b 0,1,2,0,1,2,0,1,2,0,1,2,0
dc.b 1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1
mt_arp: moveq #0,d0
move.b mt_counter(pc),d0
move.b mt_arplist(pc,d0.w),d0
beq.s mt_arp0
cmp.b #2,d0
beq.s mt_arp2
mt_arp1:moveq #0,d0
move.b 3(a4),d0
lsr.b #4,d0
bra.s mt_arpdo
mt_arp2:moveq #0,d0
move.b 3(a4),d0
and.b #$f,d0
mt_arpdo:
asl.w #1,d0
move.w $10(a4),d1
and.w #$fff,d1
lea mt_periods(pc),a0
moveq #$24,d2
mt_arp3:cmp.w (a0)+,d1
bge.s mt_arpfound
dbf d2,mt_arp3
mt_arp0:move.w $10(a4),6(a5)
rts
mt_arpfound:
move.w -2(a0,d0.w),6(a5)
rts
mt_normper:
move.w $10(a4),6(a5)
rts
mt_com: move.w 2(a4),d0
and.w #$fff,d0
beq.s mt_normper
move.b 2(a4),d0
and.b #$f,d0
tst.b d0
beq.s mt_arp
cmp.b #1,d0
beq.s mt_portup
cmp.b #2,d0
beq.s mt_portdown
cmp.b #3,d0
beq mt_port
cmp.b #4,d0
beq mt_vib
cmp.b #5,d0
beq.s mt_volport
cmp.b #6,d0
beq.s mt_volvib
move.w $10(a4),6(a5)
cmp.b #$a,d0
beq.s mt_volslide
rts
mt_portup:
moveq #0,d0
move.b 3(a4),d0
sub.w d0,$10(a4)
move.w $10(a4),d0
cmp.w #$71,d0
bpl.s mt_portup2
move.w #$71,$10(a4)
mt_portup2:
move.w $10(a4),6(a5)
rts
mt_portdown:
moveq #0,d0
move.b 3(a4),d0
add.w d0,$10(a4)
move.w $10(a4),d0
cmp.w #$358,d0
bmi.s mt_portdown2
move.w #$358,$10(a4)
mt_portdown2:
move.w $10(a4),6(a5)
rts
mt_volvib:
bsr mt_vib2
bra.s mt_volslide
mt_volport:
bsr mt_port2
mt_volslide:
moveq #0,d0
move.b 3(a4),d0
lsr.b #4,d0
beq.s mt_vol3
add.b d0,$13(a4)
cmp.b #$40,$13(a4)
bmi.s mt_vol2
move.b #$40,$13(a4)
mt_vol2:moveq #0,d0
move.b $13(a4),d0
move.w d0,8(a5)
rts
mt_vol3:move.b 3(a4),d0
and.b #$f,d0
sub.b d0,$13(a4)
bpl.s mt_vol4
clr.b $13(a4)
mt_vol4:moveq #0,d0
move.b $13(a4),d0
move.w d0,8(a5)
rts
mt_com2:move.b $2(a4),d0
and.b #$f,d0
cmp.b #$e,d0
beq.s mt_filter
cmp.b #$d,d0
beq.s mt_pattbreak
cmp.b #$b,d0
beq.s mt_songjmp
cmp.b #$c,d0
beq.s mt_setvol
cmp.b #$f,d0
beq.s mt_setspeed
rts
mt_filter:
move.b 3(a4),d0
and.b #1,d0
asl.b #1,d0
and.b #$fd,$bfe001
or.b d0,$bfe001
rts
mt_pattbreak:
move.b #1,mt_break
rts
mt_songjmp:
move.b #1,mt_break
move.b 3(a4),d0
subq.b #1,d0
move.b d0,mt_songpos
rts
mt_setvol:
cmp.b #$40,3(a4)
bls.s mt_sv2
move.b #$40,3(a4)
mt_sv2: moveq #0,d0
move.b 3(a4),d0
move.b d0,$13(a4)
move.w d0,8(a5)
rts
mt_setspeed:
moveq #0,d0
move.b 3(a4),d0
cmp.b #$1f,d0
bls.s mt_sp2
moveq #$1f,d0
mt_sp2: tst.w d0
bne.s mt_sp3
moveq #1,d0
mt_sp3: move.b d0,mt_speed
rts
mt_amhandler:
moveq #3,d7
lea mt_voice1,a6
lea $dff0a0,a5
mt_amloop:
tst.w 30(a6)
beq mt_anrp
move.w 34(a6),d0
mulu #120,d0
move.l _adr_data2,a0
lea 24(a0,d0.l),a0
tst.w 38(a6)
beq mt_anrp
cmp.w #1,38(a6)
bne.s mt_anat
move.w 32(a6),d0
cmp.w 8(a0),d0
beq.s mt_aaeq
cmp.w 8(a0),d0
blt.s mt_aaad
move.w 10(a0),d0
sub.w d0,32(a6)
move.w 32(a6),d0
cmp.w 8(a0),d0
bgt mt_anxt
move.w 8(a0),32(a6)
mt_aaeq:move.w #2,38(a6)
bra mt_anxt
mt_aaad:move.w 10(a0),d0
add.w d0,32(a6)
move.w 32(a6),d0
cmp.w 8(a0),d0
blt mt_anxt
move.w 8(a0),32(a6)
bra.s mt_aaeq
mt_anat:cmp.w #2,38(a6)
bne.s mt_ana2
move.w 32(a6),d0
cmp.w 12(a0),d0
beq.s mt_a2eq
cmp.w 12(a0),d0
blt.s mt_a2ad
move.w 14(a0),d0
sub.w d0,32(a6)
move.w 32(a6),d0
cmp.w 12(a0),d0
bgt mt_anxt
move.w 12(a0),32(a6)
mt_a2eq:move.w #3,38(a6)
bra mt_anxt
mt_a2ad:move.w 14(a0),d0
add.w d0,32(a6)
move.w 32(a6),d0
cmp.w 12(a0),d0
blt mt_anxt
move.w 12(a0),32(a6)
bra.s mt_a2eq
mt_ana2:cmp.w #3,38(a6)
bne.s mt_andc
move.w 32(a6),d0
cmp.w 16(a0),d0
beq.s mt_adeq
cmp.w 16(a0),d0
blt.s mt_adad
move.w 18(a0),d0
sub.w d0,32(a6)
move.w 32(a6),d0
cmp.w 16(a0),d0
bgt.s mt_anxt
move.w 16(a0),32(a6)
mt_adeq:move.w #4,38(a6)
move.w 20(a0),40(a6)
bra.s mt_anxt
mt_adad:move.w 18(a0),d0
add.w d0,32(a6)
move.w 32(a6),d0
cmp.w 16(a0),d0
blt.s mt_anxt
move.w 16(a0),32(a6)
bra.s mt_adeq
mt_andc:cmp.w #4,38(a6)
bne.s mt_anst
subq.w #1,40(a6)
bpl.s mt_anxt
move.w #5,38(a6)
bra.s mt_anxt
mt_anst:move.w 24(a0),d0
sub.w d0,32(a6)
bpl.s mt_anxt
clr.l 30(a6)
clr.w 38(a6)
move.w 26(a6),$dff096
mt_anxt:move.w 32(a6),d0
lsr.w #2,d0
move.w d0,8(a5)
move.w 28(a0),d0
add.w d0,16(a6)
move.w 30(a0),d1
beq.s mt_nvib
move.w 36(a6),d2
moveq #0,d3
cmp.w #360,d2
blt.s mt_vibq
sub.w #360,d2
moveq #1,d3
mt_vibq:lea mt_amsinus,a2
muls (a2,d2.w),d1
asr.w #7,d1
tst.w d3
beq.s mt_nvib
neg.w d1
mt_nvib:add.w 16(a6),d1
move.w d1,6(a5)
move.w 32(a0),d0
add.w d0,d0
add.w d0,36(a6)
cmp.w #720,36(a6)
blt.s mt_anrp
sub.w #720,36(a6)
mt_anrp:lea $10(a5),a5
lea 42(a6),a6
dbra d7,mt_amloop
lea mt_noisewave,a0
move.w #$7327,d0
moveq #31,d1
mt_nlop:move.b d0,(a0)+
add.b $dff007,d0
eor.w #124,d0
rol.w #3,d0
dbra d1,mt_nlop
rts
mt_periods:
dc.w $358,$328,$2fa,$2d0,$2a6,$280,$25c,$23a,$21a,$1fc,$1e0
dc.w $1c5,$1ac,$194,$17d,$168,$153,$140,$12e,$11d,$10d,$fe
dc.w $f0,$e2,$d6,$ca,$be,$b4,$aa,$a0,$97,$8f,$87
dc.w $7f,$78,$71,0
mt_speed: dc.b 6
mt_counter: dc.b 0
mt_pattpos: dc.w 0
mt_songpos: dc.b 0
mt_break: dc.b 0
mt_dmacon: dc.w 0
mt_samplestarts:dcb.l $1f,0
mt_voice1: dcb.w 13,0
dc.w 1
dcb.w 7,0
mt_voice2: dcb.w 13,0
dc.w 2
dcb.w 7,0
mt_voice3: dcb.w 13,0
dc.w 4
dcb.w 7,0
mt_voice4: dcb.w 13,0
dc.w 8
dcb.w 7,0
section data,DATA_C
mt_amsinus:
dc.w 0,2,4,6,8,$b,$d,$f,$11,$14,$16,$18,$1a,$1c,$1e,$21
dc.w $23,$25,$27,$29,$2b,$2d,$2f,$32,$34,$36,$38,$3a,$3c,$3e
dc.w $3f,$41,$43,$45,$47,$49,$4b,$4d,$4e,$50,$52,$53,$55,$57
dc.w $58,$5a,$5c,$5d,$5f,$60,$62,$63,$64,$66,$67,$68,$6a,$6b
dc.w $6c,$6d,$6e,$6f,$71,$72,$73,$74,$74,$75,$76,$77,$78,$79
dc.w $79,$7a,$7b,$7b,$7c,$7c,$7d,$7d,$7e,$7e,$7e,$7f,$7f,$7f
dc.w $7f,$7f,$7f,$7f,$80,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7e,$7e
dc.w $7e,$7d,$7d,$7c,$7c,$7b,$7b,$7a,$79,$79,$78,$77,$76,$75
dc.w $74,$73,$72,$71,$6f,$6e,$6d,$6c,$6b,$6a,$68,$67,$66,$64
dc.w $63,$62,$60,$5f,$5d,$5c,$5a,$58,$57,$55,$53,$52,$50,$4e
dc.w $4d,$4b,$49,$47,$45,$43,$41,$40,$3e,$3c,$3a,$38,$36,$34
dc.w $32,$2f,$2d,$2b,$29,$27,$25,$23,$21,$1e,$1c,$1a,$18,$16
dc.w $14,$11,$f,$d,$b,$8,$6,$4,$2,0
mt_amwaveforms:
dc.b 0,25,49,71,90,106,117,125
dc.b 127,125,117,106,90,71,49,25
dc.b 0,-25,-49,-71,-90,-106,-117
dc.b -125,-127,-125,-117,-106
dc.b -90,-71,-49,-25
dc.b -128,-120,-112,-104,-96,-88,-80,-72,-64,-56,-48
dc.b -40,-32,-24,-16,-8,0,8,16,24,32,40,48,56,64,72,80
dc.b 88,96,104,112,120
dcb.b 16,-128
dcb.b 16,127
mt_noisewave:
dcb.b 32,0